#include "PreCompile.hpp"
#include "LanguagesTests.hpp"

namespace BuildNG
{
  LanguagesTests::LanguagesTests()
  {
    proj = Project::load_from_file("TestFiles/LanguagesTests.buildng");
  }

  void LanguagesTests::test_cpp_keywords_in_c()
  {
    Glib::RefPtr<Module> module = proj->get_module("CWithCppKeywords");
    bool build_res = module->build("out/",StdErrorListener::create());
    assert(build_res == true);
  }

  void LanguagesTests::test_cpp_file_in_c_module()
  {
    Glib::RefPtr<DOMErrorListener> error_listener = DOMErrorListener::create(
      DOMErrorListener::Flag_IgnoreWarnings);

    Glib::RefPtr<Module> module = proj->get_module("CppFileInCModule");
    bool build_res = module->build("out/",error_listener);
    assert(build_res == false);

    assert(error_listener->module_reports.size() == 1);

    Glib::RefPtr<DOMErrorListener::ModuleReport> module_report = 
      error_listener->module_reports[0];
    assert(module_report->module == module);

    assert(module_report->errors.size() == 1);
    // assert(module_report->errors[0].location_info.file_name == "LanguagesTests.buildng");
    // TODO: check error location
  }

  void LanguagesTests::test_c_file_in_cpp_module()
  {
    Glib::RefPtr<Module> module = proj->get_module("CFileInCppModule");
    bool build_res = module->build("out/",StdErrorListener::create());
    assert(build_res == true);
  }
}
